
import 'dart:io';

import 'package:valovault_reminder/common/config/val_assets_name.dart';
import 'package:flutter/material.dart';

class ValHomeCarBodyCell extends StatefulWidget {
  final String imageName;
  final String title;
  final String content;

  final Function()? onTap;                               //点击事件
  final Function()? onTapDelete;

  const ValHomeCarBodyCell({super.key, this.onTap, this.imageName = '', this.title = '',
    this.content = '', this.onTapDelete});

  @override
  State<ValHomeCarBodyCell> createState() => _ValHomeCarBodyCellState();
}

class _ValHomeCarBodyCellState extends State<ValHomeCarBodyCell> {

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: widget.onTap,
      child: Container(
        height: 72 + 16,
        margin: const EdgeInsets.only(left: 20, right: 20, bottom: 16),
        decoration: BoxDecoration(
          gradient: const LinearGradient(
            begin: Alignment.centerLeft,
            end: Alignment.centerRight,
            colors: [
              Color(0xFFE8A229),
              Color(0xFFF9C03D),
              Color(0xFFFCCC41),
            ],
          ),
          borderRadius: BorderRadius.circular(10),
        ),
        child: Container(
            margin: const EdgeInsets.only(left: 30, right: 30, top: 12, bottom: 12),
            child: Row(
              children: [
                Container(
                  width: 48,
                  clipBehavior: Clip.hardEdge,
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(10),
                  ),
                  child: widget.imageName.contains('flutter-images') ? Image.file(File(Directory.systemTemp.path + widget.imageName), width: 48, height: 48, fit: BoxFit.fill,) : Image.asset('${ValAssetsName.ASSETS_HOME}${widget.imageName}', width: 48, height: 48, fit: BoxFit.fill),
                  // child: Image.asset('${CsConfig.ASSETS_HOME}${widget.imageName}', width: 48, height: 48, fit: BoxFit.fill),
                ),
                Expanded(
                  child: Container(
                    margin: const EdgeInsets.only(left: 22, right: 16, top: 9, bottom: 8),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        SizedBox(
                          height: 20,
                          child: Text(widget.title,
                            style: const TextStyle(color: Colors.black, fontSize: 18, fontWeight: FontWeight.w500), overflow: TextOverflow.clip,),
                        ),
                        const Padding(padding: EdgeInsets.only(top: 4)),
                        Expanded(
                          child: Text(widget.content,
                            style: const TextStyle(color: Color(0xFF666666), fontSize: 10), overflow: TextOverflow.clip,),
                        ),
                        const Padding(padding: EdgeInsets.only(top: 6)),
                      ],
                    ),
                  ),
                ),
                SizedBox(
                  height: 32,
                  child: GestureDetector(
                    onTap: widget.onTapDelete,
                    child: Image.asset('${ValAssetsName.ASSETS_HOME}val_home_delete_btn.png', width: 32, height: 32,),
                  ),
                ),
              ],
            )
        ),

      ),
    );
  }
}
